﻿@using viBook.Models
@model IEnumerable<Author>
@{
    ViewBag.Title = "Authors";
    ViewBag.Menu = "Management";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
@(Html.Telerik().Grid(Model)
               .Name("author-data-grid")
               .ToolBar(commands => commands.Insert())
               .DataKeys(keys => keys.Add(author => author.Id))
               .Columns(columns =>
                            {
                                columns.Bound(author => author.AuthorName)
                                    .Template(@<text>
@Html.ActionLink(item.AuthorName, "Details", "Authors")
</text>
                                    )
                                    .ClientTemplate(string.Format("<a href='/Authors/Details/<#= Id #>'><#= AuthorName #></a>"))
                                    .Title("Tag");
                                columns.Bound(author => author.NumberOfBook).ReadOnly();
                                columns.Command(c =>
                                                    {
                                                        c.Edit();
                                                        c.Delete();
                                                    }).Width(200);
                            })
.DataBinding(dataBinding =>
{
    dataBinding.Server().Select("Authors", "Admins");
    dataBinding.Ajax().Select("SelectAuthorAjax", "Admins").Enabled(true);
    dataBinding.Ajax().Insert("InsertAuthorAjax", "Admins").Enabled(true);
    dataBinding.Ajax().Update("UpdateAuthorAjax", "Admins").Enabled(true);
    dataBinding.Ajax().Delete("DeleteAuthorAjax", "Admins").Enabled(true);
})
.Editable(editing => editing.Mode(GridEditMode.InLine))
.Scrollable()
.Sortable()
.Pageable()
.Footer(true)
)